package com.ssm.jvm.str;

public class StringTest {


    public static String getB() {
        return "b";
    }

    public static void main(String[] args) {
        String a = "ab";
        final String b = getB();
        String c = "a" + b;


        boolean b1 = a == c; // false
        System.out.println(b1);

        sout5();

        sout4();

        sout3();

        sout2();

        sout1();


        System.out.println("String Test!");
    }

    private static void sout5() {
        String a = "ab";
        final String bb = "b";
        String b = "a" + bb;

        System.out.println(a == b); // true
    }

    private static void sout4() {
        String a = "ab";
        String bb = "b";
        String b = "a" + bb;

        System.out.println(a == b); // false
    }

    private static void sout3() {
        String a = "a3.14";
        String b = "a" + 3.14;

        boolean b1 = a == b; // true
    }

    private static void sout2() {
        String s0 = "abc";
        String s1 = new String("abc");
        String s2 = "a" + new String("bc");

        boolean b0 = s0 == s1; //false
        System.out.println(b0);
        b0 = s0 == s2; //false
        System.out.println(b0);
        b0 = s1 == s2; //false
        System.out.println(b0);
    }

    private static void sout1() {
        String s0 = "abc";
        String s1 = "abc";
        String s2 = "a" + "bc";

        boolean b1 = s0 == s1; // true
        boolean b2 = s1 == s2; // true
    }

}
